<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改范围管理-需求管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-requirement-edit" th:object="${pmpScopeRequirement}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control">[[*{description}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="beginTime" th:value="${#dates.format(pmpScopeRequirement.beginTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="endTime" th:value="${#dates.format(pmpScopeRequirement.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">需求负责人：</label>
                <div class="col-sm-8">
                    <input name="director" th:field="*{director}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">优先级：</label>
                <div class="col-sm-8">
                    <select name="priority" class="form-control m-b" th:with="type=${@dict.getType('common_size_high')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{priority}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">来源类型：</label>
                <div class="col-sm-8">
                    <select name="sourceType" class="form-control m-b" th:with="type=${@dict.getType('pmp_requirement_source')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sourceType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">关注人列表：</label>
                <div class="col-sm-8">
                    <input name="followerList" th:field="*{followerList}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('pmp_requirement_status')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                    </select>
                </div>
            </div>

            <div class='form-group'>
                <label class="col-sm-3 control-label">字典选择：</label>
                <!-- 由于input-group会清除padding, 因此需要手动再指定 -->
                <div class="col-sm-8 input-group" style="padding-left: 15px; padding-right: 15px">
                    <input class='form-control' type='text' name='projectId' value='' id='projectId'>
                    <span class='input-group-addon input-sm' onclick='selectDictTree(1, this)'><i class='fa fa-search'></i></span>
                </div>

            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/requirement";
        $("#form-requirement-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-requirement-edit').serialize());
            }
        }

        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });




        // 选择字典处理函数
        function selectDictTree(columnId, obj) {
            let dictType = $.common.nullToStr($(obj).parent().find("input").val());
            let url = ctx + "system/dict/selectDictTree/" + columnId + "/" + dictType;
            let options = {
                title: '选择字典类型',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            // 打开小窗
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            let body = layer.getChildFrame('body', index);
            let columnId = body.find('#columnId').val();
            let dictType = body.find('#dictType').val();
            // 关闭小窗
            layer.close(index);
            $("#projectId").val(dictType);
        }
    </script>
</body>
</html>
